<#escape x as (x)!?html>
    <#import "/page/Utils.ftl" as utils/>
<head>
    <script type="text/javascript">
        var menuId = "Settings_Channel";

        function add() {
            $("#addForm").submit();
        }

        function edit(e) {
            var tr = e.parent().parent();
            var passport = tr.find("input[@name='passport']").val();

            $("#editForm").find("input[@name='passport']").val(passport);
            $("#editForm").submit();
        }

    </script>
</head>
<body>

<form id="addForm" method="GET" action="add.action">
</form>

<form id="editForm" method="GET" action="edit.action">
    <input type="hidden" name="passport"/>
</form>

<table>
    <caption>
        <div class="tools border">Query Channel:
            <input type="button" value="Add" class="btn" onclick="add()"/>
        </div>
    </caption>
</table>
<table>
    <caption>
        <div class="tools border">
            <form id="mainForm" action="query.action" method="GET">
                <input name="page" type="hidden"/>
                <input name="count" type="hidden"/>
                <table class="form_table">
                    <tr>
                        <td class="key">Code:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.code?html}"
                                   name="condition.code"> &nbsp;
                        </td>
                        <td class="key">ID:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.id?html}"
                                   name="condition.id"> &nbsp;
                        </td>
                        <td class="key">Name:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.name?html}"
                                   name="condition.name"> &nbsp;
                        </td>
                        <td class="key">Passport:&nbsp;</td>
                        <td class="value">
                            <input type="text" class="text" value="${condition.passport?html}"
                                   name="condition.passport"> &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="8" align="right"><input type="submit" value="Search" class="btn">&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>

    </caption>
    <thead>
    <tr>
        <th>Passport</th>
        <th>ID</th>
        <th>Code</th>
        <th>Name</th>
        <th>IATA</th>
        <th>UserName</th>
        <th>Password</th>
        <th>Require Percent Tax</th>
        <th>Inclusive Tax Rate:</th>
        <th>Operation</th>
    </tr>
    </thead>
    <tbody>
        <#list channels as channel>
        <tr class="${(channel_index%2==0)?string('even','odd')}">
            <td>${channel.passport}<input type="hidden" name="passport"
                                                 value="${channel.passport}"/></td>
            <td>${channel.id}</td>
            <td>${channel.code}</td>
            <td>${channel.name}</td>
            <td>${channel.iataNumber}</td>
            <td>${channel.userName}</td>
            <td>${channel.password}</td>
            <td>${channel.taxPolicy}</td>
            <td>${channel.inclusiveTaxRate?string('Y','N')}</td>
            <td><input type="button" value="Edit" class="btn" onclick="edit($(this))"/>&nbsp;</td>
        </tr>
        </#list>
    <tbody>
    <tfoot>
        <#if paginator?exists>
        <tr>
            <td colspan="100" class="tools">
                <div class="paginator">
                <@utils.paging paginator "navigate" 20/>
                    <script type="text/javascript">
                        function navigate(page, count) {
                            $("#mainForm > input[name='page']").val(page);
                            $("#mainForm > input[name='count']").val(count);
                            $("#mainForm").submit();
                        }
                    </script>
                </div>
                &nbsp;</td>
        </tr>
        </#if>
    </tfoot>
</table>
</body>
</#escape>